]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
window-tracker: Also listen for changes in the gtk-application-id
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 13 Oct 2014 00:20:22 +0000 (17:20 -0700)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 13 Oct 2014 00:20:22 +0000 (17:20 -0700)
Wayland applications don't tend to have very useful WM Class properties,
as GTK+ isn't very good at picking an appropriate application ID. While
we should likely fix GTK+ to pick a better app ID, we do have the
existing gtk_shell for more accurate information. The only problem is
that the gtk_surface is set after the MetaWindow is constructed, and
we're not listening for changes on the GTK+ application ID.

Listen to changes on the GTK+ application ID to fix app tracking for
most GTK+ applications under Wayland.

src/shell-window-tracker.c

index 512f7ec1e9432de92b7e7cec640037f7c0887ed6..5c490085e17c66daba86cccbfe25d71aa02546ce 100644 (file)
@@ -448,12 +448,9 @@ update_focus_app (ShellWindowTracker *self)
 }
 
 static void
-on_wm_class_changed (MetaWindow  *window,
-                     GParamSpec  *pspec,
-                     gpointer     user_data)
+tracked_window_changed (ShellWindowTracker *self,
+                        MetaWindow         *window)
 {
-  ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data);
-
   /* It's simplest to just treat this as a remove + add. */
   disassociate_window (self, window);
   track_window (self, window);
@@ -462,6 +459,24 @@ on_wm_class_changed (MetaWindow  *window,
   update_focus_app (self);
 }
 
+static void
+on_wm_class_changed (MetaWindow  *window,
+                     GParamSpec  *pspec,
+                     gpointer     user_data)
+{
+  ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data);
+  tracked_window_changed (self, window);
+}
+
+static void
+on_gtk_application_id_changed (MetaWindow  *window,
+                               GParamSpec  *pspec,
+                               gpointer     user_data)
+{
+  ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data);
+  tracked_window_changed (self, window);
+}
+
 static void
 track_window (ShellWindowTracker *self,
               MetaWindow      *window)
@@ -476,6 +491,7 @@ track_window (ShellWindowTracker *self,
   g_hash_table_insert (self->window_to_app, window, app);
 
   g_signal_connect (window, "notify::wm-class", G_CALLBACK (on_wm_class_changed), self);
+  g_signal_connect (window, "notify::gtk-application-id", G_CALLBACK (on_gtk_application_id_changed), self);
 
   _shell_app_add_window (app, window);
 
@@ -508,6 +524,7 @@ disassociate_window (ShellWindowTracker   *self,
 
   _shell_app_remove_window (app, window);
   g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_wm_class_changed), self);
+  g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_gtk_application_id_changed), self);
 
   g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0);